package com.happyclub.pojo;

import org.hibernate.annotations.GenericGenerator;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.util.Date;
import java.util.List;
import java.util.Objects;

/**
 * @author 高欢
 * @description TODO
 * @date 2019/4/4
 */
@Entity
@Table(name = "TB_PRODUCT", schema = "SCOTT")
@EntityListeners(AuditingEntityListener.class)
public class TbProduct {
    private String id;
    private String productName;
    private String productDescript;
    private Double price;
    private String imgUrl;
    private Long productIshot;
    private Long upper;
    private Long lookNum;
    private Long sellNum;
    private Date updateTime;
    private Date createTime;
    private List<TbProductColor> colorList;
    private List<TbProductSize> sizeList;

    @Transient
    public List<TbProductColor> getColorList() {
        return colorList;
    }

    public void setColorList(List<TbProductColor> colorList) {
        this.colorList = colorList;
    }

    @Transient
    public List<TbProductSize> getSizeList() {
        return sizeList;
    }

    public void setSizeList(List<TbProductSize> sizeList) {
        this.sizeList = sizeList;
    }

    @Id
    @Column(name = "ID")
    @GenericGenerator(name="idGenerator", strategy="uuid") //这个是hibernate的注解/生成32位UUID
    @GeneratedValue(generator="idGenerator")
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    @Basic
    @Column(name = "PRODUCT_NAME")
    public String getProductName() {
        return productName;
    }

    public void setProductName(String productName) {
        this.productName = productName;
    }

    @Basic
    @Column(name = "PRODUCT_DESCRIPT")
    public String getProductDescript() {
        return productDescript;
    }

    public void setProductDescript(String productDescript) {
        this.productDescript = productDescript;
    }

    @Basic
    @Column(name = "PRICE")
    public Double getPrice() {
        return price;
    }

    public void setPrice(Double price) {
        this.price = price;
    }

    @Basic
    @Column(name = "IMG_URL")
    public String getImgUrl() {
        return imgUrl;
    }

    public void setImgUrl(String imgUrl) {
        this.imgUrl = imgUrl;
    }

    @Basic
    @Column(name = "PRODUCT_ISHOT")
    public Long getProductIshot() {
        return productIshot;
    }

    public void setProductIshot(Long productIshot) {
        this.productIshot = productIshot;
    }

    @Basic
    @Column(name = "UPPER")
    public Long getUpper() {
        return upper;
    }

    public void setUpper(Long upper) {
        this.upper = upper;
    }

    @Basic
    @Column(name = "LOOK_NUM")
    public Long getLookNum() {
        return lookNum;
    }

    public void setLookNum(Long lookNum) {
        this.lookNum = lookNum;
    }

    @Basic
    @Column(name = "SELL_NUM")
    public Long getSellNum() {
        return sellNum;
    }

    public void setSellNum(Long sellNum) {
        this.sellNum = sellNum;
    }

    @Basic
    @Column(name = "UPDATE_TIME")
    @LastModifiedDate
    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    @Basic
    @Column(name = "CREATE_TIME")
    @CreatedDate
    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        TbProduct tbProduct = (TbProduct) o;
        return Objects.equals(id, tbProduct.id) &&
                Objects.equals(productName, tbProduct.productName) &&
                Objects.equals(productDescript, tbProduct.productDescript) &&
                Objects.equals(price, tbProduct.price) &&
                Objects.equals(imgUrl, tbProduct.imgUrl) &&
                Objects.equals(productIshot, tbProduct.productIshot) &&
                Objects.equals(upper, tbProduct.upper) &&
                Objects.equals(lookNum, tbProduct.lookNum) &&
                Objects.equals(sellNum, tbProduct.sellNum) &&
                Objects.equals(updateTime, tbProduct.updateTime) &&
                Objects.equals(createTime, tbProduct.createTime);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, productName, productDescript, price, imgUrl, productIshot, upper, lookNum, sellNum, updateTime, createTime);
    }
}
